package nix.bs.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import nix.bs.service.BookService;
import nix.servlet.BaseServlet;

public class BookServlet extends BaseServlet {

	private BookService bookService = new BookService();

	public String findAll(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		request.setAttribute("bookList", bookService.findAll());
		return "f:/bs/jsps/book/list.jsp";
	}

	public String findByCategory(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		String cid = request.getParameter("cid");
		request.setAttribute("bookList", bookService.findByCategory(cid));
		return "f:/bs/jsps/book/list.jsp";
	}

	public String load(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String bid = request.getParameter("bid");
		request.setAttribute("book", bookService.load(bid));
		return "f:/bs/jsps/book/desc.jsp";
	}
}
